package com.dao.impl;

import com.dao.OrderDao;
import com.pojo.Order;
import com.utils.JDBCUtil;

import java.util.List;

public class OrderDaoImpl implements OrderDao {

    /**
     * 添加订单
     * @param order
     * @return
     */
    @Override
    public int addOrder(Order order) {
        return JDBCUtil.update("insert into s_order values(?,?,?,?)",order.getId(),order.getCreateTime(),order.getReceivingAddress(),order.getUserId());
    }

    /**
     * 删除订单
     * @param id
     * @return
     */
    @Override
    public int deleteByID(String id) {
        return JDBCUtil.update("delete from s_order where id = ? ",id);
    }

    /**
     * 根据用户ID查询所有
     * @param user_ID
     * @return
     */
    @Override
    public List<Order> selectByUserID(String user_ID) {
        return JDBCUtil.queryList(Order.class,"select * from s_order where user_id = ?",user_ID);
    }
}
